﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using UMEVOR.BLL;
using UMEVOR.DTO;
using UMEVOR.VO;

public partial class Portal_palestraImp : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack && !this.IsCallback)
        {
            if (!Session["id"].ToString().Equals(""))
            {
                int codigo = Int32.Parse(Session["id"].ToString());

                BLLT_PALESTRA bllPalestra = new BLLT_PALESTRA();
                BLLT_CASA_ESPIRITA bllCasaEspirita = new BLLT_CASA_ESPIRITA();

                lblCasaEspirita.Text = bllCasaEspirita.obterPorPK(codigo).TX_NOME_INSTITUICAO;

                gvPalestra.DataSource = bllPalestra.consultar("", codigo, DateTime.Parse("01/01/0001"));
                gvPalestra.DataBind();
            }
        }
    }
    protected void gvPalestra_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        int codigo = Int32.Parse(Session["id"].ToString());
        BLLT_PALESTRA bllPalestra = new BLLT_PALESTRA();
        gvPalestra.DataSource = bllPalestra.consultar("", codigo, DateTime.Parse("01/01/0001"));
        gvPalestra.DataBind();
    }
    protected void gvPalestra_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.DataItem != null)
        {
            VOT_PALESTRA palestra = (VOT_PALESTRA)e.Row.DataItem;

            Label lblHora = (Label)e.Row.FindControl("lblHora");

            string hora = palestra.HR_PALESTRA.ToString("HH:mm");

            if (hora.Equals("00:00"))
                hora = "";

            lblHora.Text = palestra.DT_PALESTRA.ToString("dd/MM/yyyy") + " " + hora;
        }
    }
}
